package com.example.xianzhi.dao.impl;

import com.example.xianzhi.dao.TypeDao;
import com.example.xianzhi.entity.TbType;
import com.example.xianzhi.service.TypeService;
import com.example.xianzhi.service.impl.TypeServiceImpl;
import com.example.xianzhi.util.ORMUtil;

import java.util.List;
import java.util.Map;

public class TypeDaoImp  implements TypeDao {



    @Override
    public List<TbType> selectType() {

        String sql=" SELECT * FROM tb_type";
        List<TbType> tbTypes = new ORMUtil().selectList(TbType.class, sql);
        return tbTypes;
    }

    @Override
    public int insertType(String type_name) {
        String sql=" INSERT INTO tb_type(type_name) VALUES(?)";
        int i = new ORMUtil().executeDML(sql, type_name);
        return i;
    }

    @Override
    public int deleteType(int type_id) {
        String sql="DELETE FROM tb_type WHERE type_id=?";

        int i = new ORMUtil().executeDML(sql, type_id);

        return i;
    }

    @Override
    public List<TbType> selectType_id(String type_name) {
        String sql=" SELECT type_id FROM tb_type WHERE type_name=?";
        List<TbType> tbTypes = new ORMUtil().selectList(TbType.class, sql, type_name);
        return tbTypes;
    }
    @Override
    public List<TbType> selectgoodsuser() {

        String sql=" SELECT * FROM tb_type";
        List<TbType> tbTypes = new ORMUtil().selectList(TbType.class, sql);
        return tbTypes;
    }

}
